Skip to content

Bdms 227 jab updates to pass tests#255

Closed
jacob-a-brown wants to merge 230 commits into
bdms-227from
bdms-227-jab-updates-to-pass-tests
Closed

Bdms 227 jab updates to pass tests#255
jacob-a-brown wants to merge 230 commits into
bdms-227from
bdms-227-jab-updates-to-pass-tests

Conversation

@jacob-a-brown

Copy link
Copy Markdown
Contributor

This PR implements model/schema updates to pass all well additional information tests except for the aquifer/geology tests. Those will get implemented after the models have been finalized.

@chasetmartin:

  • the feature step the response should include the source of the completion information seems to apply to the completion date of the well, is that correct?
  • the feature step the response should include the source of the construction information seems to apply to the construction method of the well, is that correct?
  • should other fields, like the driller name, also have a source?

ksmuczynski and others added 30 commits October 17, 2025 09:42
A polymorphic Notes table was needed to store all unstructured notes.

This commit creates the necessary polymorphic Notes table. Its purpose is to store all unstructured notes, categorized by a note_type. It should be used when a record might need more than one note,
when the notes need to be categorized, or when you need the ability to
search across all notes in the system. This is different from a dedicated
notes field on a specific table, which should be used to store a single,
intrinsic attribute of the record itself.
This commit introduces a new category, `notable_type`, to the
`lexicon.json` file. This category will serve as the central,
authoritative source for the controlled vocabulary used in the
polymorphic `noteable_type` columns
Removed the TODO comments about updating the lexicon file with 'notable_type' category and values. They have been added.
Added NotesMixin to db/base.py that provides polymorphic note capabilities to any model
that inherits from it. The mixin offers:

- A polymorphic one-to-many relationship to the Notes table using the notable_id/notable_type pattern
- Efficient loading with selectin strategy to prevent N+1 query issues
- A convenient add_note() factory method for creating new notes with proper polymorphic associations
- Clean separation between read (relationship) and write (method) operations

This mixin enables consistent note-taking across multiple entity types while maintaining
type safety and relationship integrity.
Added the NotesMixin to both Location and Thing models to enable polymorphic note
capabilities. This allows:

- Associating multiple categorized notes with locations and things
- Consistent note handling across entity types
- Type-safe access to notes through relationship loading
- Efficient loading of notes with selectin strategy

The NotesMixin provides both the notes relationship and add_note() method for these
models, enabling a clean API for both reading and creating notes.
…ation models

- Created new Pydantic schema for the Notes model
- Added polymorphic relationship `notes: List[NoteResponse] = []` to Thing and
  Location schemas for flexible data modeling.
- Resolved SQLAlchemy inspection error caused by circular import between
  Notes and Thing/Location models
- Updated relationship definitions in notes.py to use string-based
  SQL expressions instead of direct class references
- Maintained TYPE_CHECKING imports for proper type hinting while
  avoiding runtime circular dependencies
- Fixed the NotesMixin.add_note method by replacing the undefined
  pk_value reference with self.id
- This resolves the "Unresolved reference 'pk_value'" error in base.py
- Ensures proper note creation through the convenient factory method
- Complements previous circular import fixes in the polymorphic
  relationship structure

The change maintains the intended functionality of creating notes
associated with model instances while fixing a reference error
that was preventing proper execution.
The lexicon incorrectly categorized a type of note as `noteable_type`. It has been corrected to `note_type`

This resolves the error where tests for the location model were unable to locate the proper "note_type".
- Comment out string-type notes fields from CreateLocation and UpdateLocation schemas
- Ensure LocationResponse consistently uses notes as List[NoteResponse]
- Fix validation error where API was receiving string notes but expecting list type
- Complete transition to polymorphic notes relationship for location entities
- Update test data to create proper Note objects instead of using string values

This resolves the ResponseValidationError where the API expected notes to be a list
but received a string value ('these are some test notes').
jacob-a-brown and others added 26 commits November 18, 2025 11:04
# Conflicts:
#	transfers/well_transfer.py
@jacob-a-brown

Copy link
Copy Markdown
Contributor Author

the comparison to bdms 227 is broken and outdated. i'm going to close this and open a new one and that will hopefully fix this bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants